package com.mspbots.rule.queue.timeentry;

import com.mspbots.api.service.TenantUserTimeEntryService;
import com.mspbots.cw.request.TenantTimeEntryDTO;
import com.mspbots.rule.exceptions.cw.CwBaseRule;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @ClassName com.mspbots.rule.queue.timeentry.OverlappedQueue
 * @Description TODO
 * @Author Jun
 * @Date 2019/9/2 15:53
 * @Version 1.0
 **/
@Slf4j
@Component
public class OverlappedQueue extends TimeEntryBaseQueue {

    private static final String RULE_NAME = "Overlapped";

    @Autowired
    private TenantUserTimeEntryService tenantUserTimeEntryService;

    @RabbitListener(queues = "trigger.timeEntry.Overlapped")
    public void onQueue(TenantTimeEntryDTO tenantTimeEntryDTO) {
        try {
            CwBaseRule instance = getInstance(RULE_NAME, tenantTimeEntryDTO);
            instance.setTenantUserTimeEntryService(tenantUserTimeEntryService);
            fire(instance, tenantTimeEntryDTO);
        } catch (Exception e) {

        }


    }

}
